<?php

class kcInflector extends Doctrine_Inflector
{
  public static function urlize($text)
  {
    // Remove all non url friendly characters with the unaccent function
    $text = self::unaccent($text);
    
    // Remove all none word characters
    $text = preg_replace('/\W/', ' ', $text);
    
    // More stripping. Replace spaces with dashes
    $text = strtolower(preg_replace('/[^A-Z^a-z^0-9^\/]+/', '_',
                       preg_replace('/([a-z\d])([A-Z])/', '\1_\2',
                       preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2',
                       preg_replace('/::/', '/', $text)))));
    
    return trim($text, '_');
  }
}
